#pragma once
#include<errno.h>
#include "sqlite3.h"
#include "debug_print.h"

extern int errno;

struct database 
{
    sqlite3 *db;
    sqlite3_stmt *send_email, *list_email, *del_email,*send_user_info,*list_user_info,*del_user_info;
};

struct message_email 
{
    int id;
    int length;
    struct message_email *next;
    char content[];
};

int database_open(struct database *db, const char *file);
int database_close(struct database *db);

int database_send_email(struct database *db, const char *user, const char *message);
struct message_email *database_list_email(struct database *db, const char *user);
int database_delete_email(struct database *db, int id);

int database_send_user_info(struct database *db, const char *user, const char *password);
struct message_email *database_list_user_info(struct database *db, const char *user,const char *password);
int database_delete_user_info(struct database *db, int id);
